package com.example.two.service.impl;

import com.example.two.domain.Order;
import com.example.two.mapper.OrderMapper;
import com.example.two.mapper.UserMapper;
import com.example.two.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public boolean insertOrder(Order order) {
        return orderMapper.insertOrder(order) > 0;
    }

    @Override
    public boolean deleteOrder(Long id) {
        return orderMapper.deleteOrder(id) > 0;
    }

    @Override
    public Order getOrderById(Long id) {
        return orderMapper.getOrderById(id);
    }

    @Override
    public List<Order> getAllOrders() {
        return orderMapper.getAllOrders();
    }

    @Override
    public List<Order> getOrdersByUserId(Long userId) {
        return orderMapper.getOrdersByUserId(userId);
    }
}
